const _TIMED_LOGIN_IDLE_THRESHOLD = 5.0;
const _CONFLICTING_SESSION_DIALOG_TIMEOUT = 60;
+Gio._promisify(Gio.File.prototype, 'load_contents_async');
+
export const UserListItem = GObject.registerClass({
Signals: {'activate': {}},
}, class UserListItem extends St.Button {
() => this._updateBanner().catch(logError));
this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_TEXT_KEY}`,
() => this._updateBanner().catch(logError));
+ this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_SOURCE_KEY}`,
+ () => {
+ if (this._updateBannerMessageFile())
+ this._updateBanner().catch(logError);
+ });
+ this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_PATH_KEY}`,
+ () => {
+ if (this._updateBannerMessageFile())
+ this._updateBanner().catch(logError);
+ });
this._settings.connect(`changed::${GdmUtil.DISABLE_USER_LIST_KEY}`,
this._updateDisableUserList.bind(this));
this._settings.connect(`changed::${GdmUtil.LOGO_KEY}`,
this._bannerLabel.clutter_text.line_wrap = true;
this._bannerLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
bannerBox.add_child(this._bannerLabel);
+
+ this._updateBannerMessageFile();
this._updateBanner().catch(logError);
this._sessionMenuButton = new SessionMenuButton();
this._authPrompt.cancelButton.visible = cancelVisible;
}
+ _updateBannerMessageFile() {
+ const path = this._settings.get_string(GdmUtil.BANNER_MESSAGE_SOURCE_KEY) === 'file'
+ ? this._settings.get_string(GdmUtil.BANNER_MESSAGE_PATH_KEY)
+ : null;
+ const file = path
+ ? Gio.File.new_for_path(path)
+ : null;
+
+ if (!file && !this._bannerMessageFile)
+ return false;
+
+ if (file && this._bannerMessageFile && this._bannerMessageFile.equal(file))
+ return false;
+
+ this._bannerMessageMonitor?.disconnectObject(this);
+ this._bannerMessageMonitor = null;
+
+ this._bannerMessageFile = file;
+
+ if (file) {
+ this._bannerMessageMonitor = file.monitor_file(Gio.FileMonitorFlags.NONE, null);
+ this._bannerMessageMonitor.connectObject(
+ 'changed', () => this._updateBanner().catch(logError), this);
+ }
+
+ return true;
+ }
+
async _getBannerText() {
const enabled = this._settings.get_boolean(GdmUtil.BANNER_MESSAGE_KEY);
if (!enabled)
return null;
- // placeholder
- await false;
+ if (this._bannerMessageFile) {
+ try {
+ const [contents] = await this._bannerMessageFile.load_contents_async(null);
+ return new TextDecoder().decode(contents);
+ } catch (e) {
+ console.error(`Failed to read banner from ${this._bannerMessageFile.get_path()}: ${e.message}`);
+ return null;
+ }
+ }
return this._settings.get_string(GdmUtil.BANNER_MESSAGE_TEXT_KEY);
}
export const FINGERPRINT_AUTHENTICATION_KEY = 'enable-fingerprint-authentication';
export const SMARTCARD_AUTHENTICATION_KEY = 'enable-smartcard-authentication';
export const BANNER_MESSAGE_KEY = 'banner-message-enable';
+export const BANNER_MESSAGE_SOURCE_KEY = 'banner-message-source';
export const BANNER_MESSAGE_TEXT_KEY = 'banner-message-text';
+export const BANNER_MESSAGE_PATH_KEY = 'banner-message-path';
export const ALLOWED_FAILURES_KEY = 'allowed-failures';
export const LOGO_KEY = 'logo';